package com.homework.test2;

import java.util.Random;

public class Demo8 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(99 - 1 + 1) + 1;
        }
        for (int i : arr) {
            System.out.print(i+" ");
        }
        System.out.println();

        int dayuavg = getScore(arr);

        System.out.println("arr中大于平均值的元素的个数为"+dayuavg);
    }

    private static int getScore(int[] a) {
        double sum = 0;
        for (int i : a) {
            sum+=i;
        }
        double avg = sum/ a.length;
        int count = 0;
        for (int i : a) {
            if (i>avg){
                count++;
            }
        }
        return count;
    }
}
